package com.duolaibei.business.view.goods.mode;

import com.duolaibei.business.utils.GsonUtil;
import com.google.gson.Gson;

import org.greenrobot.greendao.annotation.Convert;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.converter.PropertyConverter;

import java.io.Serializable;
import java.util.List;

import org.greenrobot.greendao.annotation.Generated;

@Entity
public class FormatsBean implements Serializable {

    private static final long serialVersionUID = -2622462409330551942L;
    /**
     * title : 多来贝
     * data : [{"name":"100","state":"0"},{"name":"200","state":"0"},{"name":"300","state":"0"}]
     */
    @Id(autoincrement = true)
    private Long id;
    private String title;
    public boolean isChoosed;
    public int formatNum;

    @Convert(converter = EmpPointListConvert.class, columnType = String.class)
    private List<DataBean> data;

    public boolean isChoosed() {
        return isChoosed;
    }

    public void setChoosed(boolean choosed) {
        isChoosed = choosed;
    }

    public int getFormatNum() {
        return formatNum;
    }

    public void setFormatNum(int formatNum) {
        this.formatNum = formatNum;
    }

    @Generated(hash = 2072598286)
    public FormatsBean(Long id, String title, boolean isChoosed, int formatNum, List<DataBean> data) {
        this.id = id;
        this.title = title;
        this.isChoosed = isChoosed;
        this.formatNum = formatNum;
        this.data = data;
    }

    @Generated(hash = 893556270)
    public FormatsBean() {
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public List<DataBean> getData() {
        return data;
    }

    public void setData(List<DataBean> data) {
        this.data = data;
    }

    public Long getId() {
        return this.id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public boolean getIsChoosed() {
        return this.isChoosed;
    }

    public void setIsChoosed(boolean isChoosed) {
        this.isChoosed = isChoosed;
    }

    public static class EmpPointListConvert implements PropertyConverter<List<DataBean>, String> {
        @Override
        public List<DataBean> convertToEntityProperty(String databaseValue) {
            return GsonUtil.jsonToList(databaseValue, DataBean.class);
        }

        @Override
        public String convertToDatabaseValue(List<DataBean> entityProperty) {
            return GsonUtil.GsonString(entityProperty);
        }
    }

    public static class DataBean implements Serializable {
        private static final long serialVersionUID = 958638119547495303L;
        /**
         * name : 100
         * state : 0
         */

        private String name;
        private String state;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getState() {
            return state;
        }

        public void setState(String state) {
            this.state = state;
        }

        @Override
        public String toString() {
            return "DataBean{" +
                    "name='" + name + '\'' +
                    ", state='" + state + '\'' +
                    '}';
        }
    }

    @Override
    public String toString() {
        return "FormatsBean{" +
                "id=" + id +
                ", title='" + title + '\'' +
                ", isChoosed=" + isChoosed +
                ", formatNum=" + formatNum +
                ", data=" + data +
                '}';
    }
}
